package com.djakapm.swing.component.table;

import java.util.Vector;

import javax.swing.JScrollPane;

public class TableView extends JScrollPane {
	private static final long serialVersionUID = 85966086088869393L;
	private Table table;
	
	public TableView(Vector<Vector<Object>> rows,Vector<String> columns) {
		this.table = new Table(rows,columns);
		this.getViewport().setView(this.table);
	}
	
	public TableView(Vector<String> columns) {
		this.table = new Table(new Vector<Vector<Object>>(),columns);
		this.getViewport().setView(this.table);
	}
	
	public TableView(Table table) {
		super(table);
		this.table = table;
		this.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_AS_NEEDED);
		this.setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_AS_NEEDED);
	}
	
	public TableView addRow(Object... cellValues) {
		this.table.addRow(cellValues);
		return this;
	}
	
	public TableView addRow(Vector<Object> row) {
		this.table.addRow(row);
		return this;
	}
	
	public void clear(){
		this.table.clear();
	}
	

}
